#include "comm.hpp"

int main()
{
    // 获取共享内存
    int shmid = getshm();

    // 挂接到进程地址空间
    char *shmaddr = (char *)shmat(shmid, nullptr, 0);

    int fd = open(PATH, O_WRONLY);
    if (fd < 0)
    {
        log(Fatal, "open error:%s", strerror(errno));
        exit(FIFO_OPEN_ERR);
    }

    // 开始通信
    while(true)
    {
        cout << "Please Enter@ ";
        fgets(shmaddr,size,stdin);

        write(fd,"c",1);    //往管道写入 读段阻塞就解除了
    }

    // 去关联
    shmdt(shmaddr);

    return 0;
}